package cn.itsource.hrm.utils;

import cn.itsource.hrm.domain.dto.LoginUserInfo;
import com.alibaba.fastjson.JSON;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;

public class UserContextHolder {

    public static LoginUserInfo get(){
        //获取用户的信息
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();

        LoginUserInfo userInfo = JSON.parseObject(authentication.getPrincipal().toString(),LoginUserInfo.class);

        return userInfo;
    }
}
